package damo.test;

import praca.framework.FPSCounter;
import praca.framework.TextureGL;
import praca.framework.Vector;
import praca.framework.Vertices;
import praca.interfejsy.Game;
import praca.interfejsy.Screen;
import praca.interfejsy.Texture;

public class PlatekSnieguTest3 extends Screen{

	int NR = 1000;
	PlatekSniegu[] platki = new PlatekSniegu[NR];
	Vector gravity = new Vector(0 , -2);
	Vertices vert = new Vertices(100,100, true);
	Texture platek;
	FPSCounter fps = new FPSCounter();
	
	public PlatekSnieguTest3(Game game) {
		super(game);
		int len = platki.length;
		for(int i=0; i < len; i++){
			
			platki[i] = new PlatekSniegu();
		}
		
	}

	@Override
	public void update(float deltaTime) {
		
		int len = platki.length;
		for(int i=0; i < len; i++){
			platki[i].velocity.add(gravity.x* deltaTime, gravity.y* deltaTime);
			platki[i].position.add(platki[i].velocity.x * deltaTime, platki[i].velocity.y * deltaTime);
			g.clearTransformations();
			g.moveTexture(platki[i].position.x, platki[i].position.y);
			g.drawTexture(platek, vert);
			
			if(platki[i].position.y<-30){
				platki[i].reinitialize();
			}
			
		}
		
		fps.logFrame2();
		
	}

	@Override
	public void pause() {
		// TODO Auto-generated method stub
		
	}

	@Override
	public void resume() {
		g.setTextureTransparentBackground();
		platek = new TextureGL(game, "snowflake.png");
		
	}

	@Override
	public void dispose() {
		// TODO Auto-generated method stub
		
	}

}
